#include "gameinfomgr.h"
#include "DbPart.h"
#include "minutelisten.h"



GameInfoMgr::GameInfoMgr()
{
}
GameInfoMgr::~GameInfoMgr()
{
}

stGameInfo* GameInfoMgr::Get(const std::uint32_t game, const std::uint32_t agency_id)
{
    std::uint64_t uuid = MakeUuid(game, agency_id);

    auto it = m_gameinfos.find(uuid);
    if (it != m_gameinfos.end())
    {
        return &it->second;
    }

    stGameInfo gameinfo;
    if (!CDbPart::Instance()->Get(gameinfo, game, agency_id))
    {
        return nullptr;
    }
    // 同步内存
    m_gameinfos[uuid] = std::move(gameinfo);
    return &m_gameinfos[uuid];
}

stGameInfo* GameInfoMgr::RefreshGet(const std::uint32_t game, const std::uint32_t agency_id)
{
    std::uint64_t uuid = MakeUuid(game, agency_id);

    stGameInfo gameinfo;
    if (!CDbPart::Instance()->Get(gameinfo, game, agency_id))
    {
        m_gameinfos.erase(uuid);
        return nullptr;
    }
    // 同步内存
    m_gameinfos[uuid] = std::move(gameinfo);
    return &m_gameinfos[uuid];
}








